package com.grom.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.grom.bo.RootMenu;
import com.grom.bo.SecondMenu;

public abstract class MenuHolder {

	public static final String ZH_CN = "zh-cn";
	public static final String ENG = "eng";
	/**
	 * 数据库中有更新的时候将这个标志修改为true
	 */
	public static boolean needRefresh = false;

	static Map<String, List<RootMenu>> rootMenus = new HashMap<String, List<RootMenu>>();

	static Map<String, Map<String, List<SecondMenu>>> secondMenus = new HashMap<String, Map<String, List<SecondMenu>>>();

	/**
	 * 这个方法用于从数据库中抽取所有相应的数据并初始化到相应的数组
	 */
	void init() {

	}

	public List<RootMenu> getRootMenu(String location) {
		List<RootMenu> result = rootMenus.get(location);
		if (needRefresh || result == null) {
			init();
			needRefresh = false;
		}
		return result;
	}

	public Map<String, List<SecondMenu>> getSecondMenu(String location) {
		Map<String, List<SecondMenu>> result = secondMenus.get(location);
		if (needRefresh || result == null) {
			init();
			needRefresh = false;
		}
		return result;
	}
}
